// DirectDiskDlg.h : header file
//

#pragma once
#include "Disk.h"

// CDirectDiskDlg dialog
class CDirectDiskDlg;
typedef BOOL (CDirectDiskDlg::*PFNTHREAD)();
class CDirectDiskDlg : public CDialog
{
// Construction
public:
	CDirectDiskDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_DIRECTDISK_DIALOG };

	enum { KB = 1024 };
	enum { MB = (KB * KB) };
	enum { GB = (KB * MB) };
	enum { BUFF_SIZE = (5 * MB) };

	enum { COLOR_RED = RGB(255, 0, 0) };
	enum { COLOR_BLUE = RGB(0, 0, 255) };
	enum { COLOR_YELLOW = RGB(255, 255, 0) };
	enum { COLOR_BLACK = RGB(0, 0, 0) };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support

	BOOL Rescan();
	BOOL ReadAllImages();
	BOOL WriteAllImages();
	CWinThread* CreateThread(PFNTHREAD pfnThread);
	
	BOOL ReadImage(LPCTSTR lpszPhyDrv, UINT nStartSector, UINT nSectors, LPCTSTR lpszImgFile);
	BOOL WriteImage(LPCTSTR lpszPhyDrv, UINT nStartSector, LPCTSTR lpszImgFile);

	void OutputText(LPCTSTR lpszText, COLORREF crText = 0);

	void EnableAllBut(BOOL bEnable, UINT nID = 0);

// Implementation
protected:
	HICON m_hIcon;

	BOOL m_bCancel;
	UINT m_nTotalSectors;
	CString m_strImgPath; /* Image file path */
	DISK_MBR m_mbr;

	CProgressCtrl m_ctlProgress;
	CRichEditCtrl m_editOutput;
	CComboBox m_cmbImgLst;
	CComboBox m_cmbPhyDrv;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg BOOL OnDeviceChange(UINT nEventType, DWORD dwData);

	afx_msg void OnBnClickedRead();
	afx_msg void OnBnClickedWrite();
	afx_msg void OnBnClickedEject();
	afx_msg void OnBnClickedBrowse();
	afx_msg void OnBnClickedRescan();
	afx_msg void OnSelchangedPhyDrv();

	DECLARE_MESSAGE_MAP()
};
